package com.liaozibo.cloud.license.service;

import com.liaozibo.cloud.license.dao.LicenseDao;
import com.liaozibo.cloud.license.model.License;
import com.liaozibo.cloud.license.property.Tracer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author liaozibo
 * @since 2021/04/08
 **/
@Service
public class LicenseService {

    @Autowired
    private LicenseDao licenseDao;

    @Autowired
    private Tracer tracer;

    public List<License> getLicense() {
        Iterable<License> licenses = licenseDao.findAll();
        List<License> result = new ArrayList<>(2);
        licenses.forEach(license -> {
            license.setTracer(tracer.getName());
            result.add(license);
        });
        return result;
    }
}
